#ifndef CSVREADER_INC
#define CSVREADER_INC

class CSVReader
{
public:
	CSVReader(const std::string&, char ft = ',', char lt = '\n', char ec = '"');
	~CSVReader();

public:
	bool prepare(const std::string&);
	bool next();
	void over();
	std::string& operator[](size_t);
	std::string& read();
	inline void reset() { _pos = 0;				 }
	inline size_t pos()	{ return _pos;			 }
	inline size_t size(){ return _fields.size(); }
	inline size_t left()
	{
		size_t readed = pos() + 1;
		return size() > readed ? size() - readed : 0;
	}

protected:
	bool split(const std::string&, std::vector<std::string>&);

protected:
	char _ft;
	char _lt;
	char _ec;
	size_t	_pos;
	std::string	  _file;
	std::ifstream _ifs;
	std::vector<std::string> _values;
	std::vector<UInt16>	_fpositions;
	std::vector<std::string> _fields;
	std::vector<std::string> _allFields;
};

#endif